package com.taojiazheng.controller.Evaluates;

import com.taojiazheng.common.ResultResponse;
import com.taojiazheng.service.job.JobService;
import com.taojiazheng.service.user.UserEvaluateService;
import com.taojiazheng.so.job.JobEvaluatesSo;
import com.taojiazheng.so.user.UserEvaluateSo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 赵成林
 * @date 2017/11/25 17:20
 * 评论控制的路由
 * 用户的评论
 * 工作的评论
 * 需要登录才能发布评论
 * 需要购买过此商品才能发布评论
 */
@Controller
public class EvaluatesController {

    @Autowired
    private JobService jobService;
    @Autowired
    private UserEvaluateService userEvaluateService;
    @ResponseBody
    @RequestMapping(value = "createJobEvaluates",method = RequestMethod.POST)
    public ResultResponse cretaeJobEvaluates(HttpServletRequest request, @RequestBody JobEvaluatesSo jobEvaluatesSo){
        String token = request.getHeader("token");
        jobService.createJobEvaluate(jobEvaluatesSo,token);
        return new ResultResponse();
    }

    @ResponseBody
    @RequestMapping(value = "create/user/evaluate",method = RequestMethod.POST)
    public ResultResponse createUserEvaluate(HttpServletRequest request, @RequestBody UserEvaluateSo so){
        String token = request.getHeader("token");
        userEvaluateService.createUserEvaluate(token,so);
        return new ResultResponse();
    }
}
